package com.boruan.qq.zxgylibrary.ui.activities;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.boruan.qq.zxgylibrary.R;
import com.boruan.qq.zxgylibrary.R2;
import com.boruan.qq.zxgylibrary.base.BaseActivity;
import com.boruan.qq.zxgylibrary.ui.adapters.InvoiceAdapter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by 崔琦 on 2019/8/28.
 * des: 选择发票页面
 */

public class SelectInvoiceActivity extends BaseActivity {
    @BindView(R2.id.tv_no_invoice)
    TextView tvNoInvoice;
    @BindView(R2.id.rv_invoice)
    RecyclerView rvInvoice;

    private InvoiceAdapter invoiceAdapter;

    @Override
    protected int getLayoutId() {
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
        return R.layout.drug_activity_select_invoice;
    }

    @Override
    protected void init(Bundle savedInstanceState) {

        LinearLayoutManager manager = new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false);
        rvInvoice.setLayoutManager(manager);
        invoiceAdapter = new InvoiceAdapter(this);
        rvInvoice.setAdapter(invoiceAdapter);
    }

    @OnClick({R2.id.iv_back, R2.id.tv_no_invoice, R2.id.ll_add_invoice})
    public void onViewClicked(View view) {
        int i = view.getId();
        if (i == R.id.iv_back) {
            finish();

        } else if (i == R.id.tv_no_invoice) {
            Drawable drawable = getResources().getDrawable(R.mipmap.drug_pay_select_true);
            if (drawable != null) {
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); //设置边界
                tvNoInvoice.setCompoundDrawables(drawable, null, null, null);//图在左边
            }
            Intent intent = new Intent();
            intent.putExtra("invoice", "不需要");
            setResult(15, intent);
            finish();

        } else if (i == R.id.ll_add_invoice) {
            Intent intent1 = new Intent(SelectInvoiceActivity.this, NewAddInvoiceActivity.class);
            startActivity(intent1);

        }
    }
}
